package org.swift.mashup.engine.concurrency.memory;

import java.util.AbstractList;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.List;

public class MemoryList extends AbstractList<MemoryItem> {
	private BitSet mask = new BitSet();
	public BitSet getMask() {
		return mask;
	}

	private List<MemoryItem> storage = new ArrayList<MemoryItem>();

	@Override
	public boolean add(MemoryItem item) {
		this.mask.or(item.getType().getMask());		
		return super.add(item);
	}

	@Override
	public void add(int index, MemoryItem item) {
		this.mask.or(item.getType().getMask());
		storage.add(index, item);
	}

	@Override
	public MemoryItem remove(int index) {
		return storage.remove(index);
	}

	@Override
	public MemoryItem set(int index, MemoryItem element) {
		return storage.set(index, element);
	}

	@Override
	public MemoryItem get(int index) {
		return storage.get(index);
	}

	@Override
	public int size() {
		// TODO Auto-generated method stub
		return storage.size();
	}

	@Override
	public void clear() {
		this.mask = new BitSet();
		super.clear();
	}
	

}
